package com.ruyuan.eshop.common.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 商品返回信息枚举值
 *
 * @author zhonghuashishan
 * @version 1.0
 */
public enum ProductResultEnum {

    /**
     * 商品基本信息
     */
    BASE(1,"商品基本信息"),

    /**
     * 存储信息
     */
    STORAGE(2,"存储信息"),

    /**
     * 品控信息
     */
    SHELFLIFE(3,"品控信息"),

    /**
     * 图文信息
     */
    VIDEOIMG(4,"图文信息"),

    /**
     * 销售信息
     */
    SALE(5,"销售信息"),

    /**
     * 推广信息
     */
    POPULARIZE(6,"推广信息"),
    ;

    private Integer code;
    private String value;

    ProductResultEnum(Integer code, String value){
        this.code = code;
        this.value = value;
    }

    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }


    public static Map<Integer, String> toMap(){
        Map<Integer, String> map = new HashMap<>(16);
        for (ProductResultEnum element : ProductResultEnum.values() ){
            map.put(element.getCode(),element.getValue());
        }
        return map;
    }

    public static ProductResultEnum getByCode(Integer code){
        if(code == null) {
            return null;
        }
        for(ProductResultEnum element : ProductResultEnum.values()){
            if (code.equals(element.getCode())) {
                return element;
            }
        }
        return null;
    }

}
